package com.yzd.learnjava.enumerated;

import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.Set;
import java.util.TreeSet;

import com.yzd.learnjava.util.OSExecute;
import com.yzd.learnjava.util.Print;

public class Reflection {
	public static Set<String> analyze(Class<?> enumClass){
		Print.print("----------Analyzeing " + enumClass + "-------------");
		Print.print("Interfaces:");
		for(Type t : enumClass.getGenericInterfaces()) {
			Print.print(t);
		}
		
		Print.print("Base:" + enumClass.getSuperclass());
		Print.print("Methods:");
		Set<String> methods = new TreeSet<String>();
		for(Method m : enumClass.getMethods()) {
			methods.add(m.getName());
		}
		Print.print(methods);
		return methods;
	}
	
	public static void main(String[] args) {
		Set<String> exploreMethods = analyze(Explore.class);
		Set<String> enumMethods = analyze(Enum.class);
		
		Print.print("Explore.containAll(Enum)? " + exploreMethods.containsAll(enumMethods));
		
		Print.printnb("Explore.removeAll(Enum) : ");
		exploreMethods.removeAll(enumMethods);
		Print.print(exploreMethods);
		
		OSExecute.command("javap Explore");
	}
}

enum Explore{
	HERE, THERE
}
